package 动态规划;

public class LeetCode413_等差数列划分 {
    public int numberOfArithmeticSlices(int[] nums) {
        int len = nums.length;
        int[] dp = new int[len];
        int count = 0;
        for(int i = 2; i < len; i++) {
            if(nums[i] - nums[i-1] == nums[i-1] - nums[i-2]) {
                dp[i] = dp[i-1] + 1;
                count += dp[i];
            }
        }
        return count;
    }

}
